#include <stdio.h>
#include <string.h>
#define WLEN_MAX  2000002
#define WORDS_MAX 1000000


static int
insert__get_index_binsearch(char *what, char **where, int n)
{
	int L = 0, R = n-1, M;

	while (L < R) {
		M = (L + R) / 2;
		if (strcmp(what, where[M]) >= 0)
			L = M+1;
		else
			R = M;
	}
	return L;
}



static void
insert(char* what, int ind, char **array, int n)
{
	register int i;
	for (i = n; i > ind; --i) {
		array[i] = array[i-1];
	}
	array[ind] = what;
}



static void
swap_ptrs(void** a, void** b)
{
	void *T;
	T  = *a;
	*a = *b;
	*b =  T;
}



static void
Heap_sort__sift_down(char** array, int start, int end)
{
	int root = start,
	    child,
	    swap;

	while (root * 2 + 1 <= end) {
		child = root * 2 + 1;
		swap = root;

		if (strcmp(array[swap], array[child]) < 0)
			swap = child;

		if (child+1 <= end && strcmp(array[swap], array[child+1]) < 0)
			swap = child+1;

		if (swap != root) {
			swap_ptrs((void**) &array[root], (void**) &array[swap]);
			root = swap;
		} else {
			return;
		}
	}
}



static void
Heap_sort__heapify(char** array, int size)
{
	int start = size / 2 - 1;

	while (start >= 0) {
		Heap_sort__sift_down(array, start--, size - 1);
	}
}



static void
Heap_sort(char **array, int size)
{
	int end = size - 1;

	Heap_sort__heapify(array, size);

	while (end > 0) {
		swap_ptrs((void**) &array[end], (void**) &array[0]);

		Heap_sort__sift_down(array, 0, --end);
	}
}



int
main(void)
{
	int 		n;
	register int	i = 0,
			offset = 0;
	char 		array[WLEN_MAX];
	char 		*p_array[WORDS_MAX];

	freopen("words.in", "r", stdin);
	freopen("words.out", "w", stdout);

	(void)scanf("%d\n", &n);
	while (i < n) {
		(void) scanf("%s", &array[offset]);
		p_array[i] = &array[offset];
		offset += strlen(p_array[i]) + 1;
		++i;
	}

	Heap_sort(p_array, n);

	for (i = 0 ; i < n ; ++i)
		(void)printf("%s\n", p_array[i]);
	return 0;
}
